<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * App\CourseContent
 *
 * @property int $id
 * @property int $course_id 课程id
 * @property int $section_num 课程章节
 * @property string $section_name 章节名称
 * @property int $video_id 章节视频
 * @property int $file_id 章节附件
 * @property int $allow_try 允许试学
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseContent newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseContent newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseContent query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseContent whereAllowTry($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseContent whereCourseId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseContent whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseContent whereFileId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseContent whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseContent whereSectionName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseContent whereSectionNum($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseContent whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseContent whereVideoId($value)
 * @mixin \Eloquent
 * @property \Illuminate\Support\Carbon|null $deleted_at
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Query\Builder|\App\CourseContent onlyTrashed()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseContent whereDeletedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\CourseContent withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\CourseContent withoutTrashed()
 * @property int $attempt_learn_time 试学时间（秒）
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CourseContent whereAttemptLearnTime($value)
 */
class CourseContent extends Model
{
    use SoftDeletes;
    public static function getTryContents($course_id){
        if (!$course_id)
            return [];
        $data=self::whereCourseId($course_id)
            ->whereAllowTry(1)
            ->pluck('section_name')
            ->toArray();
        return $data;
    }
}
